package by.msokoloff.javaweb2015.datamodel;

import java.util.Date;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import by.msokoloff.javaweb2015.datamodel.enums.TripOrderStatus;

@Entity
@Table(name = "trip_order")
public class TripOrder extends AbstractEntity {

	@Column
	private Date orderDate;

	@Column
	private Date payDate;

	@Column
	private String payDetails;

	@Column
	private Boolean twoWay;

	@Column
	private Integer qtyAdults;

	@Column
	private Integer qtyChilds;

	@Column
	private Integer qtyInfants;

	@Column
	private Integer qtyBaggage;

	@Column
	private String customersEmail;

	@Column
	@Enumerated(EnumType.STRING)
	private TripOrderStatus status;

	@ManyToMany(targetEntity = Flight.class, fetch = FetchType.LAZY)
	@JoinTable(name = "flight_2_trip_order", joinColumns = { @JoinColumn(name = "trip_order_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "flight_id", referencedColumnName = "id") })
	private Set<Flight> flights;

	// @OneToMany(targetEntity = Registration.class, fetch = FetchType.LAZY)
	// @JoinColumn(name = "trip_order_id")
	// private Set<Registration> registrations;

	@ManyToMany(targetEntity = Extra.class, fetch = FetchType.LAZY)
	@JoinTable(name = "extra_2_trip_order", joinColumns = { @JoinColumn(name = "trip_order_id", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "extra_id", referencedColumnName = "id") })
	private Set<Extra> extras;

	public Date getOrderDate() {
		return orderDate;
	}

	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	public Date getPayDate() {
		return payDate;
	}

	public void setPayDate(Date payDate) {
		this.payDate = payDate;
	}

	public String getPayDetails() {
		return payDetails;
	}

	public void setPayDetails(String payDetails) {
		this.payDetails = payDetails;
	}

	public Boolean getTwoWay() {
		return twoWay;
	}

	public void setTwoWay(Boolean twoWay) {
		this.twoWay = twoWay;
	}

	public Integer getQtyAdults() {
		return qtyAdults;
	}

	public void setQtyAdults(Integer qtyAdults) {
		this.qtyAdults = qtyAdults;
	}

	public Integer getQtyChilds() {
		return qtyChilds;
	}

	public void setQtyChilds(Integer qtyChilds) {
		this.qtyChilds = qtyChilds;
	}

	public Integer getQtyInfants() {
		return qtyInfants;
	}

	public void setQtyInfants(Integer qtyInfants) {
		this.qtyInfants = qtyInfants;
	}

	public Integer getQtyBaggage() {
		return qtyBaggage;
	}

	public void setQtyBaggage(Integer qtyBaggage) {
		this.qtyBaggage = qtyBaggage;
	}

	public String getCustomersEmail() {
		return customersEmail;
	}

	public void setCustomersEmail(String customersEmail) {
		this.customersEmail = customersEmail;
	}

	public TripOrderStatus getStatus() {
		return status;
	}

	public void setStatus(TripOrderStatus status) {
		this.status = status;
	}

	public Set<Flight> getFlights() {
		return flights;
	}

	public void setFlights(Set<Flight> flights) {
		this.flights = flights;
	}

	public Set<Extra> getExtras() {
		return extras;
	}

	public void setExtras(Set<Extra> extras) {
		this.extras = extras;
	}

	@Override
	public String toString() {
		return "[TripOrder: " + this.id + "]";
	}

}
